package jtk.project4.fleet.field;

import java.text.SimpleDateFormat;

import jtk.project4.fleet.domain.Employee;


import nl.coderight.jazz.form.FormLayout;
import nl.coderight.jazz.form.FormLayout.Resize;
import nl.coderight.jazz.form.control.CalendarControl;
import nl.coderight.jazz.form.control.GroupControl;
import nl.coderight.jazz.form.field.TextField;

public class PersonnelInformationField extends GroupControl<Employee>{
	private TextField ssnField ;
	private CalendarControl hireDateField ;
	private CalendarControl dobField ;
	private CalendarControl dateOfLeaveField ;
	
	public PersonnelInformationField(String bindID) {
		setTitle("header.personel information");
		setBindID(bindID);
		createFields();
		createLayout();
	}
	
		
	private void createFields() {
		ssnField = new TextField("ssn", 20);
		
		hireDateField = new CalendarControl("hireDate", 20);
		hireDateField.setFormat(new SimpleDateFormat());
		hireDateField.showYearSpinner(true);
		hireDateField.setPreferredSize(ssnField.getPreferredSize());
		
		dobField = new CalendarControl("dob", 20);
		dobField.setFormat(new SimpleDateFormat());
		dobField.showYearSpinner(true);
		dobField.setPreferredSize(ssnField.getPreferredSize());
		
		dateOfLeaveField = new CalendarControl("leaveDate", 20);
		dateOfLeaveField.setFormat(new SimpleDateFormat());
		dateOfLeaveField.showYearSpinner(true);
		dateOfLeaveField.setPreferredSize(ssnField.getPreferredSize());
		
	}
	

	private void createLayout() {
		setLayout(new FormLayout())
				
			.addLabel("label.ssn")				.addField(ssnField)
			.addLabel("label.hire date")		.addField(hireDateField, Resize.HORIZONTAL)
			.addRow()
			.addLabel("label.dob")				.addField(dobField, Resize.HORIZONTAL)
			.addLabel("label.date of leave")	.addField(dateOfLeaveField, Resize.HORIZONTAL);
		
	}
}
